package com.baitiaojun.common.domain.model.result;

import com.baitiaojun.common.domain.model.tree.SysDeptTree;
import com.baitiaojun.common.domain.model.tree.SysMenuTree;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 树形结构结果集返回
 */
@Data
public class TreeResult {
    /**
     * 节点id
     */
    private Long nodeId;
    /**
     * 节点名
     */
    private String nodeName;
    /**
     * 子节点
     */
    private List<TreeResult> children;

    public TreeResult(SysDeptTree sysDeptTree) {
        this.nodeId = sysDeptTree.getDeptId();
        this.nodeName = sysDeptTree.getDeptName();
        this.children = sysDeptTree.getChildren().stream().map(TreeResult::new).collect(Collectors.toList());
    }

    public TreeResult(SysMenuTree sysMenuTree) {
        this.nodeId = sysMenuTree.getMenuId();
        this.nodeName = sysMenuTree.getMenuName();
        this.children = sysMenuTree.getChildren().stream().map(TreeResult::new).collect(Collectors.toList());
    }
}
